<script setup>
import { RouterLink, RouterView } from 'vue-router'
import HelloWorld from './components/HelloWorld.vue'
import Versions from './components/Versions.vue'

const ipcHandle = () => {
  window.electron.ipcRenderer.send('ping')
  window.electron.ipcRenderer.send('showTxt', 'Yahoo!')
  console.log(window.api.getVersion())
  let process = window.api.getProcess()
  console.log(process.getSystemMemoryInfo())
}

// 函数：在控制台输出信息
window.electron.ipcRenderer.on('pong', (event, message) => {
  console.log(message)
  console.log(window.api.getVersion())
})
</script>

<template>
  <img alt="logo" class="logo" src="./assets/electron.svg" />
  <div class="creator">Powered by electron-vite</div>
  <div class="text">
    Build an Electron App with
    <span class="vue">Vue</span>
  </div>
  <p class="tip">Please try pressing <code>F12</code> to open the devTool</p>
  <div class="actions">
    <div class="action">
      <a href="https://electron-vite.org/" target="_blank" rel="noreferrer">Documentation</a>
    </div>
    <div class="action">
      <a target="_blank" rel="noreferrer" @click="ipcHandle">Send IPC</a>
    </div>
  </div>

  <HelloWorld msg="You did it!" />

  <nav>
    <RouterLink to="/">Home</RouterLink>
    <RouterLink to="/about">About</RouterLink>
    <RouterLink to="/bigScreen">Big Screen</RouterLink>
  </nav>

  <RouterView />

  <Versions />
</template>
